#ifndef LSM303DLH_A_H_INCLUDED
#define LSM303DLH_A_H_INCLUDED


#define ACC_Mode_file "/sys/class/i2c-dev/i2c-2/device/2-0019/mode"
//#define ACC_Rate_file "/sys/class/i2c-dev/i2c-2/device/2-0019/rate"
#define ACC_Data_file "/sys/class/i2c-dev/i2c-2/device/2-0019/data"
#define ACC_Range_file "/sys/class/i2c-dev/i2c-2/device/2-0019/range"
#define ACC_Id_file "/sys/class/i2c-dev/i2c-2/device/2-0019/id"
#define ACC_Name_file "/sys/class/i2c-dev/i2c-2/device/2-0019/name"


/* Accelerometer capturing mode  */
 #define LSM303DLH_A_MODE_OFF 0x00
 #define LSM303DLH_A_MODE_NORMAL 0x01
 #define LSM303DLH_A_MODE_LP_HALF 0x02
 #define LSM303DLH_A_MODE_LP_1 0x03
 #define LSM303DLH_A_MODE_LP_2 0x02
 #define LSM303DLH_A_MODE_LP_5 0x05
 #define LSM303DLH_A_MODE_LP_10 0x06

 /* Range */
 #define LSM303DLH_A_RANGE_2G 0x00
 #define LSM303DLH_A_RANGE_4G 0x01
 #define LSM303DLH_A_RANGE_8G 0x03

/* Accelerometer output data rate */
 #define LSM303DLH_A_RATE_50 0x00
 #define LSM303DLH_A_RATE_100 0x01
 #define LSM303DLH_A_RATE_400 0x02
 #define LSM303DLH_A_RATE_1000 0x03

 /* Sensitivity adjustment */
 #define LSM303DLH_A_SENSI_2G 4 /*    1/16*/
 #define LSM303DLH_A_SENSI_4G 3 /*    2/16*/
 #define LSM303DLH_A_SENSI_8G 2 /* ~3.9/16*/

typedef struct{
	char name[16];
	short updated;
	struct {
        int id;
        int mode;
        int range;
        int rate;
        int sensi[2];
    } config;
	struct {
		float axis[3];
	} raw;
	struct {
		float axis[3];
	} filtered;
	struct {
	    /*
		float scale[3][4];
		float variance[3];
		*/
		float A_1[3*3];
		float bias[3];
	} calibration;
}acc_sensor;

void reset_values_acc(acc_sensor *acc);
int Acc_Init(acc_sensor *acc);
int Acc_write_config(acc_sensor *acc);
int Acc_read_config(acc_sensor *acc);
int Acc_read_data(acc_sensor *acc);

#endif // LSM303DLH_A_H_INCLUDED
